<html>
<head><meta charset="utf-8"><title>Extracting trait bounds from `DynTy` · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Extracting.20trait.20bounds.20from.20.60DynTy.60.html">Extracting trait bounds from `DynTy`</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="244272710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Extracting%20trait%20bounds%20from%20%60DynTy%60/near/244272710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Extracting.20trait.20bounds.20from.20.60DynTy.60.html#244272710">(Jun 29 2021 at 12:34)</a>:</h4>
<p>I'm currently trying to fix some closure inference bugs in rust-analyzer, and for that I need to look for <code>Fn&lt;X&gt;</code> bounds in a <code>DynTy</code>. Currently it seems that I'll have to write a <code>Visitor</code> for that. Am I on the right track or is there an easier way to do this?</p>



<a name="244273740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Extracting%20trait%20bounds%20from%20%60DynTy%60/near/244273740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Extracting.20trait.20bounds.20from.20.60DynTy.60.html#244273740">(Jun 29 2021 at 12:43)</a>:</h4>
<p><code>dyn_ty.bounds.skip_binders().as_slice(&amp;Interner)</code>?</p>



<a name="244273773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Extracting%20trait%20bounds%20from%20%60DynTy%60/near/244273773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Extracting.20trait.20bounds.20from.20.60DynTy.60.html#244273773">(Jun 29 2021 at 12:44)</a>:</h4>
<p>(ideally avoid skipping binders of course)</p>



<a name="244273826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Extracting%20trait%20bounds%20from%20%60DynTy%60/near/244273826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Extracting.20trait.20bounds.20from.20.60DynTy.60.html#244273826">(Jun 29 2021 at 12:44)</a>:</h4>
<p>or am I misunderstanding the question?</p>



<a name="244274290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Extracting%20trait%20bounds%20from%20%60DynTy%60/near/244274290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Extracting.20trait.20bounds.20from.20.60DynTy.60.html#244274290">(Jun 29 2021 at 12:47)</a>:</h4>
<p>a visitor doesn't really seem like the right approach if you don't want to recurse</p>



<a name="244281972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Extracting%20trait%20bounds%20from%20%60DynTy%60/near/244281972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Extracting.20trait.20bounds.20from.20.60DynTy.60.html#244281972">(Jun 29 2021 at 13:40)</a>:</h4>
<p>yeah the <code>skip_binders</code> is what I'm afraid of, I haven't found a way to avoid that short of using a visitor</p>



<a name="244281996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Extracting%20trait%20bounds%20from%20%60DynTy%60/near/244281996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Extracting.20trait.20bounds.20from.20.60DynTy.60.html#244281996">(Jun 29 2021 at 13:40)</a>:</h4>
<p>and there's two levels of binders here even</p>



<a name="244289594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Extracting%20trait%20bounds%20from%20%60DynTy%60/near/244289594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Extracting.20trait.20bounds.20from.20.60DynTy.60.html#244289594">(Jun 29 2021 at 14:25)</a>:</h4>
<p>well, it kind of depends on what you're doing with it</p>



<a name="244289783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Extracting%20trait%20bounds%20from%20%60DynTy%60/near/244289783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Extracting.20trait.20bounds.20from.20.60DynTy.60.html#244289783">(Jun 29 2021 at 14:26)</a>:</h4>
<p>if you're just checking some condition, skip_binders seems fine, though you could also use <code>map</code></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>